<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>AJAX HTML Form POST example</title>
  <script type="text/javascript" language="javascript">
    function ajaxformpost() {
      var xmlhttp;
      if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
      }
      else {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
          document.getElementById('result').innerHTML=
            "status: " + xmlhttp.status +
            "<br />statusText: " + xmlhttp.statusText +
            "<br />server response: <br />" +xmlhttp.responseText;
        }
      }
      xmlhttp.open("POST","/",true);
      xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
      xmlhttp.send("input1=" + encodeURIComponent(document.getElementById('input1').value) +
                   "&input2=" + encodeURIComponent(document.getElementById('input2').value));
    }
  </script>
</head> 
<body>
  <form action="javascript:ajaxformpost();">
     <input id="input1" type="text" size='110' value="<example1>用 HashMap &lt Name, LinkedList &lt NameDistancePair &gt &gt 的 Java data structure 畫出此 directed weighted graph。</example1>">
     <br />
     <input id="input2" type="text" size='110' value="<example2>用 HashMap &lt Name, LinkedList &lt NameDistancePair &gt &gt 的 Java data structure 畫出此 directed weighted graph。</example1>">
     <br />
     <input type="submit" value="Submit">
  </form>
  <div id="result"></div>
</body>
</html>
